package sort.comparison;

/**
 * Created by Yasin H on 2017/8/1.
 */
public class MergeBU extends Merge {

    //shortArrays 2
    //middleArrays 44
    //middleArraysR 43
    //longArrays 1004
    //longArraysR 468

//    private static Comparable[] aux;

    public static void sort(Comparable[] a) {
        int N = a.length;
        aux = new Comparable[N];
        for (int sz = 1; sz < N; sz = sz + sz) {
            for (int lo = 0; lo < N - sz; lo += sz + sz) {
                merge(a, lo, lo + sz - 1, Math.min(lo + sz + sz - 1, N - 1));
            }
        }
    }

}
